# -*-  coding:utf-8  -*-

import   unittest
import requests
from  public  import public  as p
class  case_01_login(unittest.TestCase):

    '''登录接口'''
    def  test_01_login(self):
        url = 'http://gc.ftgyun.top/bus/login/in'
        data = {"account":"admin","password":'123456'}
        res =  requests.post(url = url , data = data)
        #开始断言
        try:
            yu = 'success'
            shi = res.text
            self.assertIn(yu,shi,'登陆成功')
        except:
            self.fail('case_01_login执行失败！！')


    '''员工信息管理-查询全部'''
    def test_02_login_query(self):
        url = 'http://gc.ftgyun.top/bus/user/showAllRname'
        #前置测试用例执行
        #缓存时效    15分钟
        # token = "{}".format()
        cookie = {"token" :  p.getCookie('token')}
        res = requests.get(url = url , cookies= cookie,headers=None)
        try:
            yu = 'success'
            shi = res.text
            self.assertIn(yu,shi,'员工信息管理-查询全部成功')
        except:
            self.fail('test_02_login_query执行失败')

    '''员工信息管理-信息添加'''
    def test_03_yuangong_xinxi_tianjia(self):
        url = 'http://gc.ftgyun.top/bus/user/insertAddRole'
        #account = 'hanrui'+str(5)
        #json = {"account":  account ,"password":"123456","uname":  account,"sex":"女","age":"18","uphone":"132654","rid":"101"}
        json = {'account': 'hanrui502022_08_31_09_28_525513f', 'password': '123456', 'uname': 'hanrui502022_08_31_09_28_52888', 'sex': '女', 'age': '18', 'uphone': '132654', 'rid': '101'}
        cookie = {"token": p.getCookie('token')}
        header = {"Content-Type": "application/json"}
        #res = requests.post(url = url,json=json,cookies=cookie,headers=header)
        res = p.getRequest(url = url,method='post',data=json,cookies=cookie,header=header,Content_Type='application/json')
        try:
            yu = 'success'
            shi = res.text
            self.assertIn(yu, shi, '员工信息管理-信息添加成功')
        except:
            self.fail('test_03_yuangong_xinxi_tianjia执行失败')
